﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using TomanuExtensions;
using TomanuExtensions.Utils;

namespace AmiEmuLib.AmigaConfiguration.MountedDevicesConfig
{
    /// <summary>
    /// Base class for all disks.
    /// </summary>
    public abstract class MountedDevice : XmlBase
    {
        /// <summary>
        /// Used is DOS.
        /// </summary>
        public string DeviceName = "";

        /// <summary>
        /// Boot priority.
        /// </summary>
        public int BootPriority;

        /// <summary>
        /// In WinUAE probably not true for all disk types.
        /// </summary>
        public bool ReadOnly;

        /// <summary>
        /// ???
        /// </summary>
        public bool Bootable;

        /// <summary>
        /// ???
        /// </summary>
        public bool Mount;

        /// <summary>
        /// Constructor.
        /// </summary>
        public MountedDevice()
        {
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="a_reader"></param>
        public MountedDevice(XmlReader a_reader)
            : base(a_reader)
        {
        }

        protected override void ReadXml(XmlReader a_reader)
        {
            DeviceName = a_reader.ReadElementContentAsString("DeviceName");
            BootPriority = a_reader.ReadElementContentAsInt("BootPriority");
            ReadOnly = a_reader.ReadElementContentAsBoolean("ReadOnly");
            Bootable = a_reader.ReadElementContentAsBoolean("Bootable");
            Mount = a_reader.ReadElementContentAsBoolean("Mount");
        }

        public override void WriteXml(XmlWriter a_writer)
        {
            a_writer.WriteElement("DeviceName", DeviceName);
            a_writer.WriteElement("BootPriority", BootPriority);
            a_writer.WriteElement("ReadOnly", ReadOnly);
            a_writer.WriteElement("Bootable", Bootable);
            a_writer.WriteElement("Mount", Mount);
        }
    }
}
